<%--
  Created by IntelliJ IDEA.
  User: 22328
  Date: 2021/2/7
  Time: 22:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>商户信息编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <%--<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->--%>
    <%--<!--[if lt IE 9]>--%>
    <%--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>--%>
    <%--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>--%>
    <%--<![endif]-->--%>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form" onsubmit="return false">
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">ID</label>
                <div class="layui-input-inline">
                    <input type="text" id="userId" name="userId" value="${userInfo.id}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户状态</label>
                <div class="layui-input-inline">
                    <select id="status" name="status">
                        <c:if test="${userInfo.status == 1}">
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </c:if>
                        <c:if test="${userInfo.status == 0}">
                            <option value="0">禁用</option>
                            <option value="1">启用</option>
                        </c:if>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>商户名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username" value="${requestScope.userInfo.userName}"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>
            <div class="layui-form-item">
                <label for="age" class="layui-form-label">
                    <span class="x-red">*</span>年龄
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="age" name="age" value="${requestScope.userInfo.age}" class="layui-input">
                </div>
                <%--<div class="layui-form-mid layui-word-aux">--%>
                <%--<span class="x-red">*</span>--%>
                <%--</div>--%>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>手机
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" name="phone" value="${requestScope.userInfo.phone}"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">
                    <span class="x-red">*</span>邮箱
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="L_email" name="email" value="${requestScope.userInfo.email}"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>注意正确的邮箱格式
                </div>
            </div>
            <%--<div class="layui-form-item">--%>
            <%--<label class="layui-form-label"><span class="x-red">*</span>角色</label>--%>
            <%--<div class="layui-input-block">--%>
            <%--<input type="checkbox" name="like1[write]" lay-skin="primary" title="超级管理员" checked="">--%>
            <%--<input type="checkbox" name="like1[read]" lay-skin="primary" title="编辑人员">--%>
            <%--<input type="checkbox" name="like1[write]" lay-skin="primary" title="宣传人员" checked="">--%>
            <%--</div>--%>
            <%--</div>--%>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="L_pass" name="pass" value="${requestScope.userInfo.passWord}"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="L_repass" name="repass" value="${userInfo.passWord}"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button id="update" class="layui-btn">
                    修改
                </button>
            </div>
        </div>
    </div>
</div>
</body>
<script src="./js/jquery-3.1.0.min.js" type="text/javascript"></script>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;
        //自定义验证规则
        // form.verify({
        //     nikename: function (value) {
        //         if (value.length < 2) {
        //             return '昵称至少得2个字符啊';
        //         }
        //     },
        //     pass: [/(.+){6,12}$/, '密码必须4到12位'],
        //     repass: function (value) {
        //         if ($('#L_pass').val() != $('#L_repass').val()) {
        //             return '两次密码不一致';
        //         }
        //     }
        // });
        //监听提交
        // form.on('submit(update)',
        //     function(data) {
        //         console.log(data);
        //         //发异步，把数据提交给php
        //         layer.alert("增加成功", {
        //                 icon: 6
        //             },
        //             function() {
        //                 //关闭当前frame
        //                 xadmin.close();
        //
        //                 // 可以对父窗口进行刷新
        //                 xadmin.father_reload();
        //             });
        //         return false;
        //     });

    });
    $(function () {
        $("#update").click(function () {
            var id = $("#userId").val();
            var username = $("#username").val();
            var age = $("#age").val();
            var phone = $("#phone").val();
            var email = $("#L_email").val();
            var password = $("#L_pass").val();
            var status = $("#status").val();
            $.ajax({
                url: "./updateUser",
                type: "post",
                data: {
                    id: id,
                    username: username,
                    age: age,
                    phone: phone,
                    email: email,
                    password: password,
                    status:status
                },
                success: function (res) {
                    if (res.data === "更新成功") {
                        layer.alert("修改成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    } else {
                        layer.msg("修改失败");
                    }
                },
                error: function () {
                    alert("404.html页面");
                }
            });
        });
    });
</script>
</html>


